<?php
//last edit:: 08.04.2008

  function save_form($table, $type, $mailto, $name, $email, $vars) {
    $data = '';
    $email_body = "Name: $name\nEmail: $email\n\n";

    foreach($vars as $key => $text) {
      if(!is_array($text)) {
        $data .= $text . ":" . $_POST[$key] . "\n\n";
        $email_body .= $text . ":" . $_POST[$key] . "\n\n";
      } else {
        $keys = array_keys($text);
        foreach($_POST[$keys[0]] as $i => $null) {
          $data .= "$i.\n";
          foreach($text as $k => $t) {
            if(tep_not_null($_POST[$k][$i])) {
              $data .= "  $t:  " . $_POST[$k][$i] . "\n";
              $email_body .= "  $t:  " . $_POST[$k][$i] . "\n";
            }
          }
          $data .= "\n";
          $email_body .= "\n";
        }
      }
    }

    tep_mail('', $mailto, 'Request: ' . $type, $email_body, $name, $email);

    return true;
  }

?>
